package com.bw.exam.controller;

import com.bw.exam.result.R;
import com.bw.exam.util.OSSFileUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author: liuzhiping
 * @date: 2024/8/17 10:00
 **/
@RequestMapping("/business/image")
@RestController
@Slf4j
@CrossOrigin
public class FileController {

    @RequestMapping("/upFile")
    public R add(@RequestBody MultipartFile imageFile) throws  Exception{

        log.info("===商家添加图片====");
        OSSFileUtil ossFileUtil = new OSSFileUtil();
        String imageUrl = ossFileUtil.uploadFile(imageFile);
        //文件上次到oss服务器上 ，拿到回显地址
        log.info("===商家添加图片====【结果】 imageUrl:{}",imageUrl);

        return R.success(imageUrl);

    }

}
